home *** CD-ROM | disk | FTP | other *** search
/ Giga Games 1 / Giga Games.iso / net / usenet / volume2 / conquest / part03 < prev    next >
Encoding:
Internet Message Format  |  1987-10-26  |  54.5 KB

  1. Path: uunet!tektronix!tekgen!tekred!games-request
  2. From: games-request@tekred.TEK.COM
  3. Newsgroups: comp.sources.games
  4. Subject: v02i060:  conquest - middle earth multi-player game, Part03/05
  5. Message-ID: <1743@tekred.TEK.COM>
  6. Date: 26 Oct 87 19:03:20 GMT
  7. Sender: billr@tekred.TEK.COM
  8. Lines: 2139
  9. Approved: billr@tekred.TEK.COM
  10.  
  11. Submitted by: ihnp4!mhuxd!smile (E.BARLOW)
  12. Comp.sources.games: Volume 2, Issue 60
  13. Archive-name: conquest/Part03
  14.  
  15.  
  16.  
  17. #! /bin/sh
  18. # This is a shell archive.  Remove anything before this line, then unpack
  19. # it by saving it into a file and typing "sh file".  To overwrite existing
  20. # files, type "sh file -c".  You can also feed this as standard input via
  21. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  22. # will see the following message at the end:
  23. #        "End of archive 3 (of 5)."
  24. # Contents:  commands.c main.c reports.c run
  25. # Wrapped by billr@tekred on Mon Oct 26 10:33:05 1987
  26. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  27. if test -f commands.c -a "${1}" != "-c" ; then 
  28.   echo shar: Will not over-write existing file \"commands.c\"
  29. else
  30. echo shar: Extracting \"commands.c\" \(16412 characters\)
  31. sed "s/^X//" >commands.c <<'END_OF_commands.c'
  32. X/*conquest is copyrighted 1986 by Ed Barlow.
  33. X *  I spent a long time writing this code & I hope that you respect this.  
  34. X *  I give permission to alter the code, but not to copy or redistribute
  35. X *  it without my explicit permission.  If you alter the code, 
  36. X *  please document changes and send me a copy, so all can have it.  
  37. X *  This code, to the best of my knowledge works well,  but it is my first
  38. X *  'C' program and should be treated as such.  I disclaim any
  39. X *  responsibility for the codes actions (use at your own risk).  I guess
  40. X *  I am saying "Happy gaming", and am trying not to get sued in the process.
  41. X *                                                Ed
  42. X */
  43. X
  44. X/*    commands.c        */
  45. X
  46. X/*include files*/
  47. X#include "header.h"
  48. X#include <ctype.h>
  49. X
  50. Xextern short xcurs,ycurs,xoffset,yoffset;
  51. Xextern FILE *fexe;        /*execute file pointer*/
  52. Xextern short country;
  53. X
  54. X/*change current hex designation*/
  55. Xredesignate()
  56. X{
  57. X    char newdes;
  58. X    short x,y;
  59. X
  60. X    if(country==0){
  61. X        mvaddstr(LINES-1,0,"SUPER USER: CHANGE (v)egitation, (e)levation, (d)esig, (o)wner");
  62. X        refresh();
  63. X        switch(getch()){
  64. X        case 'e':
  65. X            /*simple contour map definitions*/
  66. X            mvprintw(LINES-2,7,"ELEVATIONS: change to %c, %c, %c, %c or %c?",WATER,PEAK,MOUNTAIN,HILL,CLEAR);
  67. X            refresh();
  68. X            newdes=getch();
  69. X            if(newdes!=WATER&&newdes!=PEAK&&newdes!=MOUNTAIN&&newdes!=HILL&&newdes!=CLEAR) return;
  70. X            sct[XREAL][YREAL].altitude=newdes;
  71. X            /*will fall through as must change vegitation*/
  72. X        case 'v':
  73. X            /*vegitation types*/
  74. X            mvprintw(LINES-2,7,"VEGITATIONS: change to %c, %c, %c, %c, %c, %c, %c, %c, %c, %c, %c or %c?",VOLCANO,DESERT,WASTE,BARREN,LT_VEG,GOOD,WOOD,FORREST,JUNGLE,SWAMP,ICE,NONE);
  75. X            refresh();
  76. X            newdes=getch();
  77. X            if(newdes!=VOLCANO&&newdes!=DESERT&&newdes!=WASTE&&newdes!=BARREN&&newdes!=LT_VEG&&newdes!=NONE&&newdes!=GOOD&&newdes!=WOOD&&newdes!=FORREST&&newdes!=JUNGLE&&newdes!=SWAMP&&newdes!=ICE) return;
  78. X            sct[XREAL][YREAL].vegitation=newdes;
  79. X            if(isdigit(sct[XREAL][YREAL].vegitation)==0) 
  80. X                sct[XREAL][YREAL].designation=newdes;
  81. X            return;
  82. X        case 'o':
  83. X            mvprintw(LINES-2,7,"what nation owner:");
  84. X            refresh();
  85. X            scanw("%hd",&x);
  86. X            sct[XREAL][YREAL].owner=x;
  87. X            return;
  88. X        }
  89. X    }
  90. X    if((country!=0)&&(sct[XREAL][YREAL].owner!=country)) {
  91. X        mvprintw(LINES-1,0,"You do not own: hit any key");
  92. X        refresh();
  93. X        getch();
  94. X        return;
  95. X    }
  96. X    mvprintw(LINES-1,0,"hit space to not redesignate anyting");
  97. X    clrtoeol();
  98. X    mvprintw(LINES-2,7,"$%d: redesignate to %c, %c, %c, %c or %c?",DESCOST,DMINE,DGOLDMINE,DFARM,DCITY,DCAPITOL);
  99. X    clrtoeol();
  100. X    refresh();
  101. X    /*read answer*/
  102. X    newdes=getch();
  103. X
  104. X    if(newdes!=DMINE&&newdes!=DGOLDMINE&&newdes!=DFARM&&newdes!=DCITY&&newdes!=DCAPITOL) return;
  105. X
  106. X    if((SOWN==country)||(country==0)) {
  107. X        if((isdigit(sct[XREAL][YREAL].vegitation)!=0)||(country==0)) {
  108. X            if(((newdes!=DCITY)&&(newdes!=DCAPITOL))||(country==0)) {
  109. X                /*decrement treasury*/
  110. X                sct[XREAL][YREAL].designation=newdes;
  111. X                if(country==0) {
  112. X                    country=sct[XREAL][YREAL].owner;
  113. X                    SADJDES;
  114. X                    country=0;
  115. X                }
  116. X                else {
  117. X                    SADJDES;
  118. X                    ntn[country].tgold-=DESCOST;
  119. X                }
  120. X            }
  121. X            else if((newdes==DCAPITOL)&&(sct[XREAL][YREAL].designation==DCITY)){
  122. X
  123. X                ntn[country].tgold-=5*DESCOST;
  124. X                ntn[country].tiron-=DESCOST;
  125. X                x=ntn[country].capx;
  126. X                y=ntn[country].capy;
  127. X                sct[x][y].designation=DCITY;
  128. X                if(country==0) {
  129. X                    country=sct[x][y].owner;
  130. X                    SADJDES2;
  131. X                    country=0;
  132. X                }
  133. X                else SADJDES2;
  134. X                sct[XREAL][YREAL].designation=newdes;
  135. X                ntn[country].capx=XREAL;
  136. X                ntn[country].capy=YREAL;
  137. X                if(country==0) {
  138. X                    country=sct[XREAL][YREAL].owner;
  139. X                    SADJDES;
  140. X                    country=0;
  141. X                }
  142. X                else SADJDES;
  143. X            }
  144. X            else if((newdes==DCAPITOL)&&(sct[XREAL][YREAL].designation!=DCITY)){
  145. X                mvprintw(LINES-1,0,"Sector must be a city: hit any key  ");
  146. X            }
  147. X            else if((ntn[country].tiron>DESCOST)&&(newdes==DCITY)){
  148. X                if(sct[XREAL][YREAL].people>=500){
  149. X                    ntn[country].tgold-=5*DESCOST;
  150. X                    ntn[country].tiron-=DESCOST;
  151. X                    sct[XREAL][YREAL].designation=newdes;
  152. X                    if(country==0) {
  153. X                        country=sct[XREAL][YREAL].owner;
  154. X                        SADJDES;
  155. X                        country=0;
  156. X                    }
  157. X                    else SADJDES;
  158. X                }
  159. X                else mvprintw(LINES-1,0,"Need 500 people to build to city");
  160. X            }
  161. X            else mvprintw(LINES-1,0,"Not enough iron: hit any key  ");
  162. X        }
  163. X        else mvprintw(LINES-1,0,"vegitation unlivable: hit any key  ");
  164. X    }
  165. X    else mvprintw(LINES-1,0,"Sorry, you don't own sector: hit any key ");
  166. X    refresh();
  167. X}
  168. X
  169. X/*build fort or ship-type */
  170. Xconstruct()
  171. X{
  172. X    int nearsea;
  173. X    int cost;
  174. X    int x,y;
  175. X    short nvynum=0;
  176. X    short mnumber,wnumber;
  177. X    short isgod=0;
  178. X    char type;
  179. X
  180. X    if(country==0){
  181. X        isgod=1;
  182. X        country=sct[XREAL][YREAL].owner;
  183. X    }
  184. X
  185. X    if(sct[XREAL][YREAL].owner!=country) {
  186. X        mvprintw(LINES-1,0,"You do not own: hit any key");
  187. X        refresh();
  188. X        getch();
  189. X        if(isgod==1) country=0;
  190. X        return;
  191. X    }
  192. X
  193. X    if((sct[XREAL][YREAL].designation==DCITY)||(sct[XREAL][YREAL].designation==DCAPITOL)) {
  194. X        /*calculate cost for fort*/
  195. X        cost=FORTCOST;
  196. X        if(isgod==1) cost=0;
  197. X        else for(x=1;x<=sct[XREAL][YREAL].fortress;x++) 
  198. X            cost*=2;
  199. X
  200. X        mvprintw(LINES-2,0,"Do you wish to construct a <f>ort (%d gold) or <s>hips:",cost);
  201. X        clrtoeol();
  202. X        refresh();
  203. X        type=getch();
  204. X    }
  205. X    else {
  206. X        mvprintw(LINES-2,0,"Must construct in city or capitol--hit any key");
  207. X        clrtoeol();
  208. X        refresh();
  209. X        getch();
  210. X        return;
  211. X    }
  212. X
  213. X    /* construct ships*/
  214. X    if (type=='s') {
  215. X        /*check if next to sea*/
  216. X        nearsea=0;
  217. X        for(x=XREAL-1;x<=XREAL+1;x++)
  218. X            for(y=YREAL-1;y<=YREAL+1;y++)
  219. X                if(sct[x][y].altitude==WATER) nearsea=1;
  220. X
  221. X        if (nearsea==0) {
  222. X            mvprintw(LINES-2,0,"not in a harbor: hit space");
  223. X            clrtoeol();
  224. X            refresh();
  225. X            getch();
  226. X            if(isgod==1) country=0;
  227. X            return;
  228. X        }
  229. X
  230. X        mvprintw(LINES-2,0,"build how many merchant ships:");
  231. X        clrtoeol();
  232. X        refresh();
  233. X        echo();
  234. X        scanw("%hd",&mnumber);
  235. X        noecho();
  236. X        mvprintw(LINES-2,0,"build how many warships:");
  237. X        clrtoeol();
  238. X        refresh();
  239. X        echo();
  240. X        scanw("%hd",&wnumber);
  241. X        noecho();
  242. X        /*sanity checks*/
  243. X        if((wnumber>100)||(wnumber<0)) wnumber=0;
  244. X        if((mnumber>100)||(mnumber<0)) mnumber=0;
  245. X        mvprintw(LINES-2,0,"constructing %hd warships and %hd merchant",wnumber,mnumber);
  246. X        clrtoeol();
  247. X
  248. X        if((nvynum=getselunit()-MAXARM)>=0){
  249. X            if(nvynum>=MAXNAVY){
  250. X                mvaddstr(LINES-1,0,"INVALID NAVY--hit any key");
  251. X                clrtoeol();
  252. X                refresh();
  253. X                getch();
  254. X                if(isgod==1) country=0;
  255. X                return;
  256. X            }
  257. X            mvaddstr(LINES-1,0,"Do you wish to raise a new fleet (y or n)");
  258. X            clrtoeol();
  259. X            refresh();
  260. X            if(getch()!='y') nvynum=(-1);
  261. X        }
  262. X
  263. X        if(nvynum<0) {
  264. X            mvprintw(LINES-2,0,"raising a new fleet");
  265. X            clrtoeol();
  266. X            refresh();
  267. X
  268. X            nvynum=0;
  269. X            x=(-1);
  270. X            while((x==(-1))&&(nvynum<MAXNAVY)) {
  271. X                if(NWAR+NMER<=0) {
  272. X                    x=nvynum;
  273. X                    NWAR=0;
  274. X                    NMER=0;
  275. X                    NADJSHP;
  276. X                }
  277. X                nvynum++;
  278. X            }
  279. X            nvynum=x;
  280. X        }
  281. X
  282. X        if(nvynum==(-1)){
  283. X            mvaddstr(LINES-1,0,"NO FREE NAVIES--hit any key");
  284. X            clrtoeol();
  285. X            refresh();
  286. X            getch();
  287. X            if(isgod==1) country=0;
  288. X            return;
  289. X        }
  290. X
  291. X        mvprintw(LINES-3,0,"Raising fleet %d",nvynum);
  292. X        if((nvynum>=0)&&(nvynum<MAXNAVY)) {
  293. X            NXLOC=XREAL;
  294. X            NYLOC=YREAL;
  295. X            NWAR+=wnumber;
  296. X            NMER+=mnumber;
  297. X            if(isgod==0) {
  298. X            ntn[country].tgold-= (int) wnumber*WARSHPCOST;
  299. X            ntn[country].tgold-= (int) mnumber*MERSHPCOST;
  300. X            }
  301. X            NMOVE=0;
  302. X            NADJSHP;
  303. X            NADJLOC;
  304. X            NADJMOV;
  305. X        }
  306. X        else mvprintw(LINES-2,0,"ERROR!!!!!!!!!!!!!");
  307. X
  308. X        refresh();
  309. X        makebottom();
  310. X    }
  311. X    /* construct fortification points*/
  312. X    else if(type=='f'){
  313. X        if(sct[XREAL][YREAL].people>=500) {
  314. X
  315. X            mvprintw(LINES-1,25,"you build one fort point for %d gold",cost);
  316. X            ntn[country].tgold-=cost;
  317. X            sct[XREAL][YREAL].fortress++;
  318. X            INCFORT;
  319. X        }
  320. X        else mvprintw(LINES-1,25,"need 500 people");
  321. X    }
  322. X    else mvprintw(LINES-1,0,"error");
  323. X
  324. X    if(isgod==1) country=0;
  325. X    refresh();
  326. X}
  327. X
  328. X/*DRAFT IF IN A CITY*/
  329. Xdraft()
  330. X{
  331. X    short armynum;
  332. X    short men=0;
  333. X    short army=(-1);
  334. X    short isgod=0;
  335. X    if(country==0) {
  336. X        isgod=1;
  337. X        country=sct[XREAL][YREAL].owner;
  338. X    }
  339. X    else if(sct[XREAL][YREAL].owner!=country) {
  340. X        mvprintw(LINES-1,0,"You do not own: hit any key");
  341. X        refresh();
  342. X        getch();
  343. X        return;
  344. X    }
  345. X
  346. X    if((sct[XREAL][YREAL].designation!=DCITY)&&(sct[XREAL][YREAL].designation!=DCAPITOL)) {
  347. X        mvprintw(LINES-1,0,"must raise in cities: hit any key");
  348. X        refresh();
  349. X        getch();
  350. X        if(isgod==1) country=0;
  351. X        return;
  352. X    }
  353. X
  354. X    if((sct[XREAL][YREAL].designation==DCITY)&&(sct[XREAL][YREAL].people*(2*CITYLIMIT+(ntn[country].tsctrs/2))<ntn[country].tciv)){
  355. X        mvprintw(LINES-1,0,"need %d people in city: hit any key",ntn[country].tciv/(2*CITYLIMIT+(ntn[country].tsctrs/2)));
  356. X        refresh();
  357. X        getch();
  358. X        if(isgod==1) country=0;
  359. X        return;
  360. X    }
  361. X
  362. X    if(ntn[country].tgold <= 0){
  363. X        mvprintw(LINES-1,0,"you dont have any gold: hit any key");
  364. X        refresh();
  365. X        getch();
  366. X        if(isgod==1) country=0;
  367. X        return;
  368. X    }
  369. X
  370. X    /*raise an untrained army */
  371. X    mvprintw(LINES-3,0,"how many men do you wish to raise");
  372. X    clrtoeol();
  373. X    refresh();
  374. X    echo();
  375. X    scanw("%hd",&men);
  376. X    noecho();
  377. X    if(men<=0) return;
  378. X    if(men > sct[XREAL][YREAL].people/4) {
  379. X        mvprintw(LINES-2,0,"can only raise %d soldiers",sct[XREAL][YREAL].people/4);
  380. X        clrtoeol();
  381. X        refresh();
  382. X        men = sct[XREAL][YREAL].people/4;
  383. X    }
  384. X    if(men > (short) 10*ntn[country].tiron) {
  385. X        mvprintw(LINES-2,0,"aborting--only enough iron for %d troops",ntn[country].tiron/10);
  386. X        clrtoeol();
  387. X        refresh();
  388. X        getch();
  389. X        if(isgod==1) country=0;
  390. X        return;
  391. X    }
  392. X    else {
  393. X        move(LINES-2,0);
  394. X        clrtoeol();
  395. X        ntn[country].tiron-= (int) 10*men;
  396. X    }
  397. X
  398. X    /*count is order of that army in sector*/
  399. X    /*armynum is number of that army*/
  400. X    if((armynum=getselunit())>=0){
  401. X        if(armynum>=MAXARM){
  402. X            mvaddstr(LINES-1,0,"INVALID ARMY--hit any key");
  403. X            clrtoeol();
  404. X            refresh();
  405. X            getch();
  406. X            if(isgod==1) country=0;
  407. X            return;
  408. X        }
  409. X        mvaddstr(LINES-1,0,"Do you wish to raise a new army");
  410. X        clrtoeol();
  411. X        refresh();
  412. X        if(getch()!='y') army=armynum;
  413. X        else army=(-1);
  414. X    }
  415. X    if(army==(-1)) {
  416. X        mvprintw(LINES-2,0,"raising a new army");
  417. X        clrtoeol();
  418. X        refresh();
  419. X        armynum=0;
  420. X        while((army==(-1))&&(armynum<MAXARM)) {
  421. X            if(ASOLD<=0) {
  422. X                army=armynum;
  423. X                ASOLD=0;
  424. X                AADJMEN;
  425. X            }
  426. X            armynum++;
  427. X        }
  428. X        if(army==(-1)){
  429. X            mvaddstr(LINES-1,0,"NO FREE ARMIES--hit any key");
  430. X            clrtoeol();
  431. X            refresh();
  432. X            getch();
  433. X            if(isgod==1) country=0;
  434. X            return;
  435. X        }
  436. X        armynum=army;
  437. X    }
  438. X
  439. X    AYLOC=YREAL;
  440. X    AXLOC=XREAL;
  441. X    AADJLOC;
  442. X    AMOVE=0;
  443. X    AADJMOV;
  444. X    ASTAT=DEFEND;
  445. X    AADJSTAT;
  446. X    ASOLD+=men;
  447. X    AADJMEN;
  448. X    sct[XREAL][YREAL].people -= men;
  449. X    SADJCIV;
  450. X    if(isgod==0)
  451. X        /*magiced get 1/2 enlistment costs*/
  452. X        if((magic(country,WARRIOR)==1)||(magic(country,WARLORD)==1)||(magic(country,CAPTAIN)==1))
  453. X            ntn[country].tgold -= (int) men*ENLISTCOST/2;
  454. X        else ntn[country].tgold -= (int) men*ENLISTCOST;
  455. X    else country=0;
  456. X}
  457. X
  458. X/*adjust picked army*/
  459. Xadjarm()
  460. X{
  461. X    short status;
  462. X    short armynum=0;
  463. X    armynum=getselunit();
  464. X    if((armynum<0)||(armynum>MAXARM)) {
  465. X        beep();
  466. X        mvprintw(LINES-1,0,"Sorry you have an Invalid army number (%d)",armynum);
  467. X        refresh();
  468. X        getch();
  469. X        return;
  470. X    }
  471. X    clear();
  472. X    mvprintw(0,10,"ADJUST ARMY %d OF NATION %s",armynum,ntn[country].name);
  473. X    mvaddstr(2,10,"1.  March ");
  474. X    mvaddstr(3,10,"2.  Scouting--will not engage enemy if possible");
  475. X    mvaddstr(4,10,"3.  Attack anybody (Hostile+) within 2 sectors");
  476. X    mvaddstr(5,10,"4.  Defend ");
  477. X    mvaddstr(6,10,"5.  Garrison--for a city or Capital");
  478. X    mvaddstr(12,10,"Enter your choice (return to continue):");
  479. X    refresh();
  480. X    echo();
  481. X    scanw("%hd",&status);
  482. X    noecho();
  483. X    if((status<1)||(status>5)) return;
  484. X    if((status==SCOUT)&&(ASOLD>25)){
  485. X        clear();
  486. X        mvaddstr(12,(COLS/2)-6,"MUST HAVE < 25 MEN TO SCOUT");
  487. X        mvaddstr(13,(COLS/2)-12,"HIT ANY KEY TO CONTINUE");
  488. X        refresh();
  489. X        getch();
  490. X        return;
  491. X    }
  492. X    ASTAT=status;
  493. X    AADJSTAT;
  494. X}
  495. X
  496. X/*go through MSGFILE not rewriting to temp messages you discard*/
  497. X/* then move temp to MSGFILE*/
  498. Xrmessage()
  499. X{
  500. X    FILE *mesgfp;
  501. X    FILE *fptemp;
  502. X    int i;
  503. X    int count;
  504. X    int contd;
  505. X    int done=0;
  506. X    char line[80];
  507. X    char save[20][80];
  508. X
  509. X    clear();
  510. X    /*open file*/
  511. X    strcpy(line,MSGFILE);
  512. X    strcat(line,":temp");
  513. X    fptemp=fopen(line,"w");
  514. X    if ((mesgfp=fopen(MSGFILE,"r"))==NULL) {
  515. X        mvprintw(0,0,"error on read of %s--hit return",MSGFILE);
  516. X        refresh();
  517. X        getch();
  518. X        return;
  519. X    }
  520. X
  521. X    /*read in file a line at at time*/
  522. X    if(fgets(line,80,mesgfp)==NULL) done=1;
  523. X    while(done==0) {
  524. X        contd=0;
  525. X        count=3;
  526. X        if(strncmp(line,ntn[country].name,strlen(ntn[country].name))==0) {
  527. X            clear();
  528. X            standout();
  529. X            /*print to end of message*/
  530. X            while(contd==0) {
  531. X                if(count<22) strcpy(save[count-3],line);
  532. X                mvprintw(count,0,"%s",line);
  533. X                standend();
  534. X                for(i=0;i<strlen(ntn[country].name);i++) 
  535. X                    mvaddch(count,i,' ');
  536. X                count++;
  537. X                if(fgets(line,80,mesgfp)==NULL) contd=1;
  538. X                if(strncmp(line,"END",3)==0) contd=1;
  539. X            }
  540. X            standout();
  541. X            mvaddstr(LINES-3,(COLS/2)-22,"HIT RETURN TO SAVE MESSAGE");
  542. X            mvaddstr(LINES-2,(COLS/2)-22,"HIT ANY OTHER KEY TO CONTINUE");
  543. X            standend();
  544. X            refresh();
  545. X            if(getch()=='\n') {
  546. X                for(i=0;i<count-3;i++) fputs(save[i],fptemp);
  547. X                strcpy(line,"END\n");
  548. X                fputs(line,fptemp);
  549. X            }
  550. X        }
  551. X        else fputs(line,fptemp);
  552. X        if(fgets(line,80,mesgfp)==NULL) done=1;
  553. X    }
  554. X    fclose(mesgfp);
  555. X    fclose(fptemp);
  556. X
  557. X    /*IMPLEMENT A MOVE BETWEEN TMP FILE AND REAL FILE HERE*/
  558. X    strcpy(line,"mv ");
  559. X    strcat(line,MSGFILE);
  560. X    strcat(line,":temp");
  561. X    strcat(line," ");
  562. X    strcat(line,MSGFILE);
  563. X    system(line);
  564. X}
  565. X
  566. Xwmessage()
  567. X{
  568. X    FILE *fp, *fopen();
  569. X    int x,y;
  570. X    int done=0;
  571. X    char ch;
  572. X    char name[12];
  573. X    int temp=(-1);
  574. X    int linedone;
  575. X    char line[100];
  576. X    int nationid;
  577. X
  578. X    /*what nation to send to*/
  579. X    clear();
  580. X    mvprintw(0,0,"to send a message to the administrator, send to 'god':");
  581. X    mvprintw(2,0,"What country name do you wish to send to:");
  582. X    refresh();
  583. X    echo();
  584. X    getstr(name);
  585. X    noecho();
  586. X
  587. X    /*is name valid*/
  588. X    for(nationid=0;nationid<MAXNTN;nationid++) if(ntn[nationid].active!=0)
  589. X        if(strcmp(name,ntn[nationid].name)==0) temp=nationid;
  590. X
  591. X    if(strcmp(name,"god")==0) temp=0;
  592. X
  593. X    if (temp==(-1)) {
  594. X        mvprintw(2,0,"error--invalid name");
  595. X        refresh();
  596. X        getch();
  597. X        return;
  598. X    }
  599. X
  600. X    if ((fp=fopen(MSGFILE,"a+"))==NULL) {
  601. X        mvprintw(4,0,"error opening %s",MSGFILE);
  602. X        refresh();
  603. X        getch();
  604. X        return;
  605. X    }
  606. X
  607. X    move(0,0);
  608. X    clrtoeol();
  609. X    move(2,0);
  610. X    clrtoeol();
  611. X    standout();
  612. X    mvprintw(3,(COLS-25)/2,"message to nation %s",name);
  613. X    mvprintw(LINES-2,(COLS-25)/2,"end with a return on a new line");
  614. X    mvprintw(LINES-1,(COLS-35)/2,"btw... This is my first editor, any comments?");
  615. X    standend();
  616. X
  617. X    fprintf(fp,"%s Message to %s from %s\n",name,name,ntn[country].name);
  618. X    fprintf(fp,"%s \n",name);
  619. X    y=6;
  620. X    x=0;
  621. X    refresh();
  622. X    while(done==0) {
  623. X        linedone=0;
  624. X        ch=' ';
  625. X        /*read line*/
  626. X        while(linedone==0){
  627. X            if(ch=='\b'){
  628. X                if(x>0) x--;
  629. X                mvaddch(y,x,' ');
  630. X                move(y,x);
  631. X                line[x]=' ';
  632. X                refresh();
  633. X                ch=getch();
  634. X            }
  635. X            else if(ch=='\n') linedone=1;
  636. X            else{
  637. X                /*concatonate to end*/
  638. X                line[x]=ch;
  639. X                mvaddch(y,x,ch);
  640. X                if(x<99) x++;
  641. X                else linedone=1;
  642. X                refresh();
  643. X                ch=getch();
  644. X            }
  645. X        }
  646. X        line[x]='\0';
  647. X        if(x<=1) done=1;
  648. X        /*write to file*/
  649. X        fprintf(fp,"%s %s\n",name,line);
  650. X        x=0;
  651. X        y++;
  652. X    }
  653. X    fputs("END\n",fp);
  654. X    mvprintw(20,0,"Done with messaging");
  655. X    fclose(fp);
  656. X}
  657. X
  658. X/*strategic move of civilians...once only*/
  659. Xmoveciv()
  660. X{
  661. X    short people;
  662. X    short i,j;
  663. X
  664. X    mvaddstr(LINES-1,0,"Moving civilians costs 50 per civilian");
  665. X    if(sct[XREAL][YREAL].owner!=country){
  666. X        mvprintw(LINES-2,0,"you do not own:  hit return");
  667. X        clrtoeol();
  668. X        refresh();
  669. X        getch();
  670. X        return;
  671. X    }
  672. X    else if(sct[XREAL][YREAL].people==0){
  673. X        mvaddstr(LINES-2,0,"nobody lives here!!!:  hit return");
  674. X        clrtoeol();
  675. X        refresh();
  676. X        getch();
  677. X        makebottom();
  678. X        return;
  679. X    }
  680. X
  681. X    clear();
  682. X    mvprintw(0,0,"sector contains %d people",sct[XREAL][YREAL].people);
  683. X    mvaddstr(1,0,"how many people to move?");
  684. X    clrtoeol();
  685. X    refresh();
  686. X    echo();
  687. X    scanw("%hd",&people);
  688. X    noecho();
  689. X    if((people<0)||(people>sct[XREAL][YREAL].people)||(people*50>ntn[country].tgold)){
  690. X        mvaddstr(4,0,"wrong oh great moosebreath...");
  691. X        clrtoeol();
  692. X        refresh();
  693. X        getch();
  694. X        makebottom();
  695. X        return;
  696. X    }
  697. X
  698. X    mvprintw(4,0,"sector location is x=%d, y=%d",XREAL,YREAL);
  699. X    mvaddstr(6,0,"what x location to move to?");
  700. X    refresh();
  701. X    echo();
  702. X    scanw("%hd",&i);
  703. X    refresh();
  704. X    noecho();
  705. X
  706. X    if((i-(XREAL))>2||(i-(XREAL))<-2) {
  707. X        mvprintw(9,0,"can only move 2 sectors (you tried %hd)...--hit any key",i-(XREAL));
  708. X        refresh();
  709. X        getch();
  710. X        return;
  711. X    }
  712. X
  713. X    mvaddstr(9,0,"what y location to move to?");
  714. X    clrtoeol();
  715. X    refresh();
  716. X    echo();
  717. X    scanw("%hd",&j);
  718. X    noecho();
  719. X    if((j-(YREAL)>2)||((YREAL)-j>2)) {
  720. X        mvprintw(9,0,"can only move 2 sectors (you tried %hd)...--hit any key",j-(XREAL));
  721. X        refresh();
  722. X        getch();
  723. X        return;
  724. X    }
  725. X    if(sct[XREAL][YREAL].owner!=country){
  726. X        mvaddstr(11,0,"you dont own it...");
  727. X        clrtoeol();
  728. X        refresh();
  729. X        getch();
  730. X        return;
  731. X    }
  732. X    ntn[country].tgold-=50*people;
  733. X    sct[XREAL][YREAL].people-=people;
  734. X    SADJCIV;
  735. X    sct[i][j].people+=people;
  736. X    SADJCIV2;
  737. X}
  738. END_OF_commands.c
  739. if test 16412 -ne `wc -c <commands.c`; then
  740.     echo shar: \"commands.c\" unpacked with wrong size!
  741. fi
  742. # end of overwriting check
  743. fi
  744. if test -f main.c -a "${1}" != "-c" ; then 
  745.   echo shar: Will not over-write existing file \"main.c\"
  746. else
  747. echo shar: Extracting \"main.c\" \(17234 characters\)
  748. sed "s/^X//" >main.c <<'END_OF_main.c'
  749. X/*conquest is copyrighted 1986 by Ed Barlow.
  750. X *  I spent a long time writing this code & I hope that you respect this.  
  751. X *  I give permission to alter the code, but not to copy or redistribute
  752. X *  it without my explicit permission.  If you alter the code, 
  753. X *  please document changes and send me a copy, so all can have it.  
  754. X *  This code, to the best of my knowledge works well,  but it is my first
  755. X *  'C' program and should be treated as such.  I disclaim any
  756. X *  responsibility for the codes actions (use at your own risk).  I guess
  757. X *  I am saying "Happy gaming", and am trying not to get sued in the process.
  758. X *                                                Ed
  759. X */
  760. X
  761. X/*include files*/
  762. X#include <ctype.h>
  763. X#include "header.h"
  764. X
  765. X/*initialization data*/
  766. X/*Movement costs*/
  767. Xchar *ele=       "#^%-~";
  768. Xchar *elename[]= {  "PEAK", "MOUNTAIN", "HILL", "FLAT","WATER"};
  769. Xchar *veg=       "VDW46973JSI~";
  770. Xchar *vegname[]= { "VOLCANO", "DESERT", "WASTE", "BARREN(4)", "LT VEG(6)",
  771. X"GOOD (9)", "WOOD (7)", "FOREST(3)", "JUNGLE", "SWAMP", "ICE", "NONE"};
  772. Xchar *numbers=   "0123456789";
  773. Xchar *Class[]= { "NPC", "king", "emperor", "wizard", "priest", "pirate", 
  774. X"trader", "tyrant", "demon", "dragon", "shadow"};
  775. Xchar *races[]= { "GOD","ORC","ELF","DWARF","LIZARD",
  776. X"HUMAN","PIRATE","BARBARIAN","NOMAD","UNKNOWN"};
  777. Xchar *diploname[]= { "UNMET", "CONFEDERACY", "ALLIED", "FRIENDLY",
  778. X"NEUTRAL", "HOSTILE", "WAR", "JIHAD"};
  779. Xchar *soldname[]= { "","MARCH","SCOUT","ATTACK","DEFEND","GARRISON"};
  780. Xchar *des=       "cCmfx$!-";
  781. Xchar *desname[]= {"CITY", "CAPITOL", "MINE", "FARM", "DEVASTATED", "GOLDMINE", 
  782. X"CASTLE", "NODESIG", "PEAK", "WATER"};
  783. X
  784. X/*Declarations*/
  785. Xstruct s_sector sct[MAPX][MAPY];
  786. Xstruct nation ntn[NTOTAL];   /* player nation stats */
  787. X
  788. X/*is sector occupied by an army?*/
  789. Xshort occ[MAPX][MAPY];
  790. Xshort movecost[MAPX][MAPY];
  791. Xextern int armornvy;
  792. Xint startgold=0;
  793. X
  794. X/*offset of upper left hand corner*/
  795. Xshort xoffset=0,yoffset=0;
  796. X/*current cursor postion (relative to 00 in upper corner)*/
  797. X/*    position is 2*x,y*/
  798. Xshort xcurs=0,ycurs=0;
  799. X/*redraw map in this turn if redraw is a 1*/
  800. Xshort redraw=TRUE;
  801. X/*1 if you have quit*/
  802. Xint done=0;
  803. X/*display state*/
  804. Xshort hilmode=0;   /*highlight modes: 0=owned sectors, 1= armies, 2=none*/
  805. Xshort dismode=2;   /*display mode: 1=vegitation, 2=desig, 3=contour*/
  806. X/*         4=armies/navies, 5=commodities, 6=fertility*/
  807. Xshort selector=0;  /*selector (y vbl) for which army/navy... is "picked"*/
  808. X/* nation id of owner*/
  809. Xshort country=0;
  810. X
  811. XFILE *fexe, *fopen();
  812. X
  813. Xmain(argc,argv)
  814. Xint argc;
  815. Xchar **argv;
  816. X{
  817. X    register int i;
  818. X    char name[20];
  819. X    void srand();
  820. X    int getopt();
  821. X    char passwd[20];
  822. X    long time();
  823. X
  824. X    srand((unsigned) time((long *) 0));
  825. X    /* process the command line arguments */
  826. X    while((i=getopt(argc,argv,"maxph"))!=EOF) switch(i){
  827. X    case 'm':  /*make a new world*/
  828. X        makeworld();
  829. X        exit(1);
  830. X    case 'a': /*anyone with password can add player*/
  831. X        readdata();
  832. X        if(strncmp(crypt(getpass("\nwhat is super user password:"),SALT),ntn[0].passwd,PASSLTH)!=0) {
  833. X            printf("sorry, must be super user to add player\n");
  834. X            exit(1);
  835. X        }
  836. X        newlogin();
  837. X        exit(1);
  838. X    case 'x': /* execute program*/
  839. X        readdata();
  840. X        update();
  841. X        writedata();
  842. X        exit(1);
  843. X    case 'p': /*print the map*/
  844. X        readdata();
  845. X        if(strncmp(crypt(getpass("\nwhat is super user password:"),SALT),ntn[0].passwd,PASSLTH)!=0) {
  846. X            printf("sorry, must be super user to get map\n");
  847. X            exit(1);
  848. X        }
  849. X        printf("what type of map\noptions are\n");
  850. X        printf("\t1) altitudes\n\t2) vegitations\n");
  851. X        printf("\t3) nations\n\n");
  852. X        printf("\tINPUT:");
  853. X        scanf("%hd",&dismode);
  854. X        if(dismode==1) printele();
  855. X        else if(dismode==2) printveg();
  856. X        else pr_ntns();
  857. X        exit(1);
  858. X    case 'h': /* execute help program*/
  859. X        initscr();
  860. X        savetty();
  861. X        noecho();
  862. X        raw();
  863. X        help();
  864. X        endwin();
  865. X        putchar('\n');
  866. X        exit(1);
  867. X    case '?': /* print out command line arguments */
  868. X        printf("Cmd line format: conquest [-maxdhp]\n\t-m   make a world\n\t-a   add new player\n\t-x   execute program\n\t-h   print help text\n\t-p   print a map\n ");
  869. X        exit(1);
  870. X    };
  871. X
  872. X    /* read data*/
  873. X    readdata();
  874. X    armornvy=AORN;
  875. X
  876. X    /* identify the player and the country he represents */
  877. X
  878. X    /* get nation name either from command line or by asking
  879. X *     if you fail will give you the name of administrator of game
  880. X */
  881. X
  882. X    /* verify existence of nation*/
  883. X    printf("conquest: copyrighted by Ed Barlow (1986)\n");
  884. X    printf("what nation would you like to be:");
  885. X    scanf("%s",name);
  886. X    if(strcmp(name,"god")==0) strcpy(name,"unowned");
  887. X    country=(-1);
  888. X    for(i=0;i<NTOTAL;i++)
  889. X        if(strcmp(name,ntn[i].name)==0) country=i;
  890. X
  891. X    if(country==(-1)) {
  892. X        printf("name not found\n");
  893. X        printf("\nfor rules type <conquest -h>");
  894. X        printf("\nfor more information please contact %s\n",OWNER);
  895. X        return;
  896. X    }
  897. X
  898. X    /*get encrypted password*/
  899. X    strcpy(passwd,crypt(getpass("\nwhat is your password:"),SALT));
  900. X    if((strncmp(passwd,ntn[country].passwd,PASSLTH)!=0)&&(strncmp(passwd,ntn[0].passwd,PASSLTH)!=0)) {
  901. X        strcpy(passwd,crypt(getpass("\nerror: reenter your password:"),SALT));
  902. X        if((strncmp(passwd,ntn[country].passwd,PASSLTH)!=0)&&(strncmp(passwd,ntn[0].passwd,PASSLTH)!=0)) {
  903. X            printf("\nsorry:");
  904. X            printf("\nfor rules type <conquest -h>");
  905. X            printf("\nfor more information on the system please contact %s\n",OWNER);
  906. X            exit(1);
  907. X        }
  908. X    }
  909. X
  910. X    /* check if user is super-user nation[0] */
  911. X    /*     else setup cursor to capitol*/
  912. X    if(country==0) {
  913. X        printf("welcome super user\n");
  914. X        xcurs=1;
  915. X        xoffset=0;
  916. X        ycurs=1;
  917. X        yoffset=0;
  918. X    }
  919. X    else {
  920. X        printf("\nverifing that nation %s exists\n",ntn[country].name);
  921. X        startgold = ntn[country].tgold;
  922. X        execute();
  923. X        if(ntn[country].capx>15) {
  924. X            xcurs=15;
  925. X            xoffset= (ntn[country].capx-15);
  926. X        }
  927. X        else {
  928. X            xcurs= ntn[country].capx;
  929. X            xoffset= 0;
  930. X        }
  931. X        if(ntn[country].capy>10) {
  932. X            ycurs=10;
  933. X            yoffset= (ntn[country].capy-10);
  934. X        }
  935. X        else {
  936. X            yoffset= 0;
  937. X            ycurs= ntn[country].capy;
  938. X        }
  939. X    }
  940. X
  941. X    updmove(ntn[country].race);
  942. X
  943. X    /* open output for future printing*/
  944. X    if ((fexe=fopen(EXEFILE,"a"))==NULL) {
  945. X        beep();
  946. X        printf("error opening %s\n",EXEFILE);
  947. X        exit(1);
  948. X    }
  949. X
  950. X    /* SET UP THE SCREEN */
  951. X    printf("about to set up the screen");
  952. X    initscr();
  953. X    savetty();
  954. X    raw();
  955. X
  956. X    prep();
  957. X    noecho();
  958. X
  959. X    /*main while routine*/
  960. X    done=0;
  961. X    while (done==0)
  962. X    {
  963. X        /* check if cursor is out of bounds*/
  964. X        if((xcurs<1)||(ycurs<1)||(xcurs>=(COLS-21)/2)||((ycurs>=LINES-5))||((XREAL)>=MAPX)||((YREAL)>=MAPY)) offmap();
  965. X
  966. X        /*update map*/
  967. X        if(redraw==TRUE) {
  968. X            clear();
  969. X            makemap();    /* update map*/
  970. X            makebottom();
  971. X            redraw=FALSE;
  972. X        }
  973. X        move(ycurs,2*xcurs);
  974. X        makeside(); /*update side*/
  975. X        move(ycurs,2*xcurs);
  976. X        refresh();
  977. X        /*get commands, make moves and input command*/
  978. X        parse();
  979. X    }
  980. X
  981. X    if(country==0) writedata();
  982. X    else {
  983. X    fprintf(fexe,"NGOLD\t%d \t%d \t%d \t0 \t0 \t%s\n",XNAGOLD ,country,ntn[country].tgold,"null");
  984. X    fprintf(fexe,"NIRON\t%d \t%d \t%d \t0 \t0 \t%s\n",XNAIRON ,country,ntn[country].tiron,"null");
  985. X    fprintf(fexe,"NRGOLD\t%d \t%d \t%d \t0 \t0 \t%s\n",XNARGOLD ,country,ntn[country].jewels,"null");
  986. X    }
  987. X    /*done so quit*/
  988. X    clear();
  989. X    printw("quitting\n");
  990. X    refresh();
  991. X    noraw();
  992. X    resetty();
  993. X    endwin();
  994. X    fclose(fexe);
  995. X    exit(1);
  996. X}
  997. X
  998. X/*make the bottom of the screen*/
  999. Xmakebottom()
  1000. X{
  1001. X    move(LINES-4,0);
  1002. X    clrtoeol();
  1003. X    mvprintw(LINES-3,0,"Conquest version %d",VERSION);
  1004. X    clrtoeol();
  1005. X    mvaddstr(LINES-1,0,"  type ? for help");
  1006. X    clrtoeol();
  1007. X    mvaddstr(LINES-2,0,"  type Q to quit");
  1008. X    clrtoeol();
  1009. X    if(country==0) mvaddstr(LINES-3,COLS-20,"nation..GOD  ");
  1010. X    else {
  1011. X        mvprintw(LINES-3,COLS-20,"nation...%s",ntn[country].name);
  1012. X        mvprintw(LINES-2,COLS-20,"treasury.%d",ntn[country].tgold);
  1013. X        mvprintw(LINES-1,COLS-20,"score....%d",ntn[country].score);
  1014. X    }
  1015. X}
  1016. X
  1017. X/* parse */
  1018. Xparse()
  1019. X{
  1020. X    register int i;
  1021. X    char name[20];
  1022. X    char passwd[12];
  1023. X    int ocountry;
  1024. X
  1025. X    switch(getch()) {
  1026. X    case ' ':    /*redraw the screen*/
  1027. X        redraw=TRUE;
  1028. X        break;
  1029. X    case 'a':    /*army report*/
  1030. X        redraw=TRUE;
  1031. X        armyrpt();
  1032. X        break;
  1033. X    case 'A':    /*adjust army*/
  1034. X        redraw=TRUE;
  1035. X        adjarm();
  1036. X        break;
  1037. X    case 'b':    /*move south west*/
  1038. X        xcurs--;
  1039. X        ycurs++;
  1040. X        break;
  1041. X    case 'B':    /*budget*/
  1042. X        redraw=TRUE;
  1043. X        budget();
  1044. X        break;
  1045. X    case 'c':    /*change nation stats*/
  1046. X        redraw=TRUE;
  1047. X        change();
  1048. X        break;
  1049. X    case 'C':    /*construct*/
  1050. X        construct();
  1051. X        break;
  1052. X    case 'd':    /*change display*/
  1053. X        newdisplay();
  1054. X        break;
  1055. X    case 'D':    /*draft*/
  1056. X        draft();
  1057. X        break;
  1058. X    case 'f': /*report on ships and load/unload*/
  1059. X        redraw=TRUE;
  1060. X        fleetrpt();
  1061. X        break;
  1062. X    case 'H':    /*scroll west*/
  1063. X        xcurs-=((COLS-22)/4);
  1064. X        break;
  1065. X    case 'h':    /*move west*/
  1066. X        xcurs--;
  1067. X        break;
  1068. X    case 'J':    /*scroll down*/
  1069. X        ycurs+=((LINES-5)/2);
  1070. X        break;
  1071. X    case 'j':    /*move down*/
  1072. X        ycurs++;
  1073. X        break;
  1074. X    case 'k':    /*move up*/
  1075. X        ycurs--;
  1076. X        break;
  1077. X    case 'K':    /*scroll up*/
  1078. X        ycurs-=((LINES-5)/2);
  1079. X        break;
  1080. X    case 'l':    /*move east*/
  1081. X        xcurs++;
  1082. X        break;
  1083. X    case 'L':    /*scroll east*/
  1084. X        xcurs+=((COLS-22)/4);
  1085. X        break;
  1086. X    case 'm':     /*move selected item to new x,y */
  1087. X        redraw=TRUE;
  1088. X        mymove();
  1089. X        prep();
  1090. X        break;
  1091. X    case 'M':     /*magic*/
  1092. X        redraw=TRUE;
  1093. X        domagic();
  1094. X        break;
  1095. X    case 'n':    /*move south-east*/
  1096. X        ycurs++;
  1097. X        xcurs++;
  1098. X        break;
  1099. X    case 'N':    /*read newspaper */
  1100. X        redraw=TRUE;
  1101. X        newspaper();
  1102. X        break;
  1103. X    case 'p':    /*pick*/
  1104. X        selector+=2;
  1105. X        if((mvinch(selector,COLS-21))!='>') selector=0;
  1106. X        break;
  1107. X    case 'P':    /*production*/
  1108. X        redraw=TRUE;
  1109. X        produce();
  1110. X        break;
  1111. X    case 'Q':    /*quit*/
  1112. X    case 'q':    /*quit*/
  1113. X        done=1;
  1114. X        break;
  1115. X    case 'r':     /*redesignate*/
  1116. X        redraw=TRUE;
  1117. X        redesignate();
  1118. X        break;
  1119. X        /*list*/
  1120. X    case 'R':     /*Read Messages*/
  1121. X        redraw=TRUE;
  1122. X        rmessage();
  1123. X        refresh();
  1124. X        break;
  1125. X    case 's':    /*score*/
  1126. X        redraw=TRUE;
  1127. X        showscore();
  1128. X        break;
  1129. X    case 'S':    /*diplomacy screens*/
  1130. X        diploscrn();
  1131. X        redraw=TRUE;
  1132. X        break;
  1133. X    case 'u':    /*move north-east*/
  1134. X        ycurs--;
  1135. X        xcurs++;
  1136. X        break;
  1137. X    case 'W':     /*message*/
  1138. X        redraw=TRUE;
  1139. X        wmessage();
  1140. X        break;
  1141. X    case 'y':    /*move north-west*/
  1142. X        ycurs--;
  1143. X        xcurs--;
  1144. X        break;
  1145. X    case 'Z':    /*move civilians up to 2 spaces*/
  1146. X        redraw=TRUE;
  1147. X        moveciv();
  1148. X        break;
  1149. X    case 'z':    /*login as new user */
  1150. X        fprintf(fexe,"NGOLD\t%d \t%d \t%d \t0 \t0 \t%s\n",XNAGOLD ,country,ntn[country].tgold,"null");
  1151. X        redraw=TRUE;
  1152. X        fprintf(fexe,"NIRON\t%d \t%d \t%d \t0 \t0 \t%s\n",XNAIRON ,country,ntn[country].tiron,"null");
  1153. X        fprintf(fexe,"NRGOLD\t%d \t%d \t%d \t0 \t0 \t%s\n",XNARGOLD ,country,ntn[country].jewels,"null");
  1154. X        standout();
  1155. X        clear();
  1156. X        mvaddstr(0,0,"change login to : ");
  1157. X        standend();
  1158. X        refresh();
  1159. X        echo();
  1160. X        scanw("%s",name);
  1161. X        noecho();
  1162. X
  1163. X        ocountry=country;
  1164. X        country=(-1);
  1165. X        if(strcmp(name,"god")==0) country=0;
  1166. X        else for(i=1;i<NTOTAL;i++)
  1167. X            if((strcmp(name,ntn[i].name)==0)&&(ntn[i].active>=1))
  1168. X                country=i;
  1169. X
  1170. X        if(country==(-1)) {
  1171. X            mvaddstr(2,0,"name not found");
  1172. X            country=ocountry;
  1173. X            break;
  1174. X        }
  1175. X
  1176. X        /*get password*/
  1177. X        mvaddstr(2,0,"what is your password:");
  1178. X        refresh();
  1179. X        getstr(passwd);
  1180. X        strcpy(name,crypt(passwd,SALT));
  1181. X
  1182. X        if((strncmp(name,ntn[country].passwd,PASSLTH)!=0)&&(strncmp(name,ntn[0].passwd,PASSLTH)!=0)){
  1183. X            mvaddstr(3,0,"sorry:");
  1184. X            refresh();
  1185. X            country=ocountry;
  1186. X            break;
  1187. X        }
  1188. X
  1189. X        readdata();
  1190. X        startgold = ntn[country].tgold;
  1191. X        execute();
  1192. X        updmove(ntn[country].race);
  1193. X        /*go to that nations capital*/
  1194. X        if(country!=0) {
  1195. X            if(ntn[country].capx>15) {
  1196. X                xcurs=15;
  1197. X                xoffset= (ntn[country].capx-15);
  1198. X            }
  1199. X            else {
  1200. X                xcurs= ntn[country].capx;
  1201. X                xoffset= 0;
  1202. X            }
  1203. X            if(ntn[country].capy>10) {
  1204. X                ycurs=10;
  1205. X                yoffset= (ntn[country].capy-10);
  1206. X            }
  1207. X            else {
  1208. X                yoffset= 0;
  1209. X                ycurs= ntn[country].capy;
  1210. X            }
  1211. X        }
  1212. X        break;
  1213. X    case '?':    /*display help screen*/
  1214. X        redraw=TRUE;
  1215. X        help();
  1216. X        break;
  1217. X    default:
  1218. X        beep();
  1219. X    }
  1220. X}
  1221. X
  1222. Xmakeside()
  1223. X{
  1224. X    int i;
  1225. X    int found=0,nvyfnd=0;
  1226. X    int enemy;
  1227. X    int y;
  1228. X    short armynum;
  1229. X    short nvynum;
  1230. X    int count;
  1231. X    int nfound=0;
  1232. X
  1233. X    /*clear side if you cant see it as you are out of bounds*/
  1234. X    if(inch()==' ') {
  1235. X        for(i=0;i<LINES-3;i++){
  1236. X            move(i,COLS-21);
  1237. X            clrtoeol();
  1238. X        }
  1239. X        return;
  1240. X    }
  1241. X
  1242. X    /*clear top right hand side each new sector*/
  1243. X    for(count=0;count<11;count++){
  1244. X        move(count,COLS-21);
  1245. X        clrtoeol();
  1246. X    }
  1247. X
  1248. X    /*check for your armies*/
  1249. X    for(armynum=0;armynum<MAXARM;armynum++){
  1250. X        /*show any of your armies in sector*/
  1251. X        if((ASOLD>0)&&(AXLOC==XREAL)&&(AYLOC==YREAL)) {
  1252. X            if(nfound<5) {
  1253. X                mvaddch(nfound*2,COLS-21,'>');
  1254. X                if(selector==nfound*2) standout();
  1255. X                mvprintw(nfound*2,COLS-20,"army %d: %d men  ",armynum,ASOLD);
  1256. X                mvprintw(nfound*2+1,COLS-20," mv:%d st:%s",AMOVE,*(soldname+ASTAT));
  1257. X                clrtoeol();
  1258. X                standend();
  1259. X                nfound++;
  1260. X            }
  1261. X            else mvaddstr(10,COLS-20,"MORE...");
  1262. X        }
  1263. X        if((occ[XREAL][YREAL]!=0)&&(occ[XREAL][YREAL]!=country)&&((SOWN==country)||((ASOLD>0)&&(AXLOC<=XREAL+1)&&(AXLOC>=XREAL-1)&&(AYLOC<=YREAL+1)&&(AYLOC>=YREAL-1)))) found=1;
  1264. X    }
  1265. X
  1266. X    for(nvynum=0;nvynum<MAXNAVY;nvynum++){
  1267. X        if(((NWAR+NMER)!=0)&&(NXLOC==XREAL)&&(NYLOC==YREAL)) {
  1268. X            if(nfound<6) {
  1269. X                mvaddstr(nfound*2,COLS-21,">");
  1270. X                if(selector==nfound*2) standout();
  1271. X                mvprintw(nfound*2,COLS-20,"navy %d: move %d",nvynum,NMOVE);
  1272. X                clrtoeol();
  1273. X                mvprintw(nfound*2+1,COLS-20," war:%d mer:%d",NWAR,NMER);
  1274. X                clrtoeol();
  1275. X                standend();
  1276. X                nfound++;
  1277. X            }
  1278. X            else mvaddstr(10,COLS-20,"MORE...");
  1279. X        }
  1280. X        if((occ[XREAL][YREAL]!=0)&&(occ[XREAL][YREAL]!=country)&&(sct[XREAL][YREAL].altitude==WATER)&&(NWAR+NMER>0)&&(NXLOC<=XREAL+1)&&(NXLOC>=XREAL-1)&&(NYLOC<=YREAL+1)&&(NYLOC>=YREAL-1)) nvyfnd=1;
  1281. X    }
  1282. X
  1283. X    count=0;
  1284. X    if(found==1) for(i=0;i<NTOTAL;i++) {
  1285. X        if(magic(i,HIDDEN)!=1){
  1286. X            enemy=0;
  1287. X            for(armynum=0;armynum<MAXARM;armynum++){
  1288. X                if((i!=country)&&(ntn[i].arm[armynum].xloc==XREAL)&&(ntn[i].arm[armynum].yloc==YREAL)&&(ntn[i].arm[armynum].sold>0)) enemy+=ntn[i].arm[armynum].sold;
  1289. X            }
  1290. X            if(enemy>0) {
  1291. X                if(magic(country,SPY)==1)
  1292. X                    mvprintw(nfound*2+count,COLS-20,"%s: %d men  ",ntn[i].name,enemy);
  1293. X                else if(magic(i,THE_VOID)==1){
  1294. X                mvprintw(nfound*2+count,COLS-20,"%s: ?? men  ",ntn[i].name);
  1295. X                clrtoeol();
  1296. X                }
  1297. X                else mvprintw(nfound*2+count,COLS-20,"%s: %d men  ",ntn[i].name,(enemy*(rand()%60+70)/100));
  1298. X                count++;
  1299. X            }
  1300. X        }
  1301. X    }
  1302. X    if(nvyfnd==1) for(i=0;i<MAXNTN;i++) {
  1303. X        if(magic(i,HIDDEN)!=1){
  1304. X            for(nvynum=0;nvynum<MAXNAVY;nvynum++){
  1305. X                if((ntn[i].arm[nvynum].xloc==XREAL)&&(ntn[i].arm[nvynum].yloc==YREAL)&&(ntn[i].arm[nvynum].sold>0)){
  1306. X                    if(magic(country,SPY)==1){
  1307. X                        mvprintw(nfound*2+count,COLS-20,"%s: %d ships  ",ntn[i].name,ntn[i].nvy[nvynum].warships+ntn[i].nvy[nvynum].merchant);
  1308. X                    }
  1309. X                    else if(magic(i,THE_VOID)==1){
  1310. X                    mvprintw(nfound*2+count,COLS-20,"%s: ?? ships",ntn[i].name);
  1311. X                    clrtoeol();
  1312. X                    }
  1313. X                    else mvprintw(nfound*2+count,COLS-20,"%s: %d ships  ",ntn[i].name,(ntn[i].nvy[nvynum].warships+ntn[i].nvy[nvynum].merchant)*(rand()%6+7)/10);
  1314. X                    count++;
  1315. X                }
  1316. X            }
  1317. X        }
  1318. X    }
  1319. X
  1320. X    standend();
  1321. X    mvprintw(11,COLS-20,"x is %d  ",XREAL);
  1322. X    mvprintw(11,COLS-11,"y is %d  ",YREAL);
  1323. X
  1324. X    if((country!=0)&&(sct[XREAL][YREAL].altitude=='~')){
  1325. X        for(y=12;y<=20;y++) mvaddstr(y,COLS-20,"                    ");
  1326. X        mvaddstr(14,COLS-9,"WATER");
  1327. X    }
  1328. X    else {
  1329. X    if((country!=0)&&(country!=sct[XREAL][YREAL].owner)&&(magic(sct[XREAL][YREAL].owner,THE_VOID)==1)){
  1330. X        for(y=13;y<=20;y++) mvaddstr(y,COLS-20,"                    ");
  1331. X    }
  1332. X    else {
  1333. X
  1334. X        for(y=13;y<=14;y++) mvaddstr(y,COLS-20,"                    ");
  1335. X
  1336. X        for(i=0;i<=7;i++)
  1337. X            if(sct[XREAL][YREAL].designation==*(des+i)){
  1338. X            mvprintw(13,COLS-20,"%s",*(desname+i));
  1339. X            clrtoeol();
  1340. X            }
  1341. X
  1342. X        if((sct[XREAL][YREAL].owner==country)||(country==0))
  1343. X        mvprintw(15,COLS-20,"people: %6d",sct[XREAL][YREAL].people);
  1344. X        else     
  1345. X        mvprintw(15,COLS-20,"people: %6d",sct[XREAL][YREAL].people*(rand()%60+70)/100);
  1346. X
  1347. X        if((sct[XREAL][YREAL].owner==country)||(sct[XREAL][YREAL].owner==0)||(sct[XREAL][YREAL].owner>=MAXNTN)){
  1348. X            mvprintw(17,COLS-20,"gold is:   %3d",sct[XREAL][YREAL].gold);
  1349. X            mvprintw(18,COLS-20,"iron is:   %3d",sct[XREAL][YREAL].iron);
  1350. X            if(sct[XREAL][YREAL].fortress>0){
  1351. X            mvprintw(19,COLS-20,"fortress:   %2d",sct[XREAL][YREAL].fortress);
  1352. X            }
  1353. X            else mvaddstr(19,COLS-20,"               ");
  1354. X        }
  1355. X        else {
  1356. X        for(y=17;y<=19;y++) mvaddstr(y,COLS-20,"                    ");
  1357. X        }
  1358. X    }
  1359. X
  1360. X    standout();
  1361. X    if(sct[XREAL][YREAL].owner==0) mvaddstr(12,COLS-20,"unowned");
  1362. X    else mvprintw(12,COLS-20,"owner: %s",ntn[sct[XREAL][YREAL].owner].name);
  1363. X    standend();
  1364. X    clrtoeol();
  1365. X
  1366. X    for(i=0;i<=10;i++)
  1367. X        if(sct[XREAL][YREAL].vegitation==*(veg+i))
  1368. X        mvprintw(13,COLS-9,"%s",*(vegname+i));
  1369. X
  1370. X    if(sct[XREAL][YREAL].owner!=0) for(i=1;i<=8;i++)
  1371. X        if(ntn[sct[XREAL][YREAL].owner].race==*(races+i)[0]){
  1372. X        mvprintw(14,COLS-20,"%s",*(races+i));
  1373. X        clrtoeol();
  1374. X        }
  1375. X
  1376. X    for(i=0;i<=4;i++)
  1377. X        if(sct[XREAL][YREAL].altitude==*(ele+i))
  1378. X        mvprintw(14,COLS-9,"%s",*(elename+i));
  1379. X    }
  1380. X
  1381. X    if(movecost[XREAL][YREAL]<0) 
  1382. X    mvaddstr(16,COLS-20,"YOU CAN'T ENTER HERE");
  1383. X    else
  1384. X    mvprintw(16,COLS-20,"move cost:  %2d      ",movecost[XREAL][YREAL]);
  1385. X
  1386. X}
  1387. X
  1388. Xoffmap()
  1389. X{
  1390. X    redraw=FALSE;
  1391. X    /*set offset offsets can not be < 0*/
  1392. X    if(xcurs<1){
  1393. X        if(XREAL<=0) {
  1394. X            xoffset=0;
  1395. X            xcurs=0;
  1396. X        }
  1397. X        else {
  1398. X            redraw=TRUE;
  1399. X            xoffset-=15;
  1400. X            xcurs+=15;
  1401. X        }
  1402. X    }
  1403. X    else if(xcurs >= (COLS-22)/2){
  1404. X        if(XREAL<MAPX) {
  1405. X            redraw=TRUE;
  1406. X            xoffset+=15;
  1407. X            xcurs-=15;
  1408. X        }
  1409. X    }
  1410. X    if(XREAL>=MAPX) xcurs=MAPX-1-xoffset;
  1411. X    if(xoffset<0) xoffset=0;
  1412. X    if(xcurs<0) xcurs=0;
  1413. X    else if(xcurs >= (COLS-22)/2) {
  1414. X        redraw=TRUE;
  1415. X        xoffset+=15;
  1416. X        xcurs-=15;
  1417. X    }
  1418. X
  1419. X    if(ycurs<1){
  1420. X        if(YREAL<=0) {
  1421. X            yoffset=0;
  1422. X            ycurs=0;
  1423. X        }
  1424. X        else {
  1425. X            redraw=TRUE;
  1426. X            ycurs+=15;
  1427. X            yoffset-=15;
  1428. X        }
  1429. X    }
  1430. X    else if(ycurs >= LINES-5){
  1431. X        if(YREAL<MAPY) {
  1432. X            redraw=TRUE;
  1433. X            yoffset+=15;
  1434. X            ycurs-=15;
  1435. X        }
  1436. X    }
  1437. X    if(YREAL>=MAPY) ycurs=MAPY-1-yoffset;
  1438. X    if(yoffset<0) yoffset=0;
  1439. X    if(ycurs<0) ycurs=0;
  1440. X    else if(ycurs >= LINES - 5) {
  1441. X        redraw=TRUE;
  1442. X        yoffset+=15;
  1443. X        ycurs-=15;
  1444. X    }
  1445. X}
  1446. END_OF_main.c
  1447. if test 17234 -ne `wc -c <main.c`; then
  1448.     echo shar: \"main.c\" unpacked with wrong size!
  1449. fi
  1450. # end of overwriting check
  1451. fi
  1452. if test -f reports.c -a "${1}" != "-c" ; then 
  1453.   echo shar: Will not over-write existing file \"reports.c\"
  1454. else
  1455. echo shar: Extracting \"reports.c\" \(17114 characters\)
  1456. sed "s/^X//" >reports.c <<'END_OF_reports.c'
  1457. X/*conquest is copyrighted 1986 by Ed Barlow.
  1458. X *  I spent a long time writing this code & I hope that you respect this.  
  1459. X *  I give permission to alter the code, but not to copy or redistribute
  1460. X *  it without my explicit permission.  If you alter the code, 
  1461. X *  please document changes and send me a copy, so all can have it.  
  1462. X *  This code, to the best of my knowledge works well,  but it is my first
  1463. X *  'C' program and should be treated as such.  I disclaim any
  1464. X *  responsibility for the codes actions (use at your own risk).  I guess
  1465. X *  I am saying "Happy gaming", and am trying not to get sued in the process.
  1466. X *                                                Ed
  1467. X */
  1468. X
  1469. X
  1470. X/*    screen subroutines    */
  1471. X
  1472. X/*include files*/
  1473. X#include <ctype.h>
  1474. X#include "header.h"
  1475. X
  1476. Xextern FILE *fexe;
  1477. Xextern short country;
  1478. Xextern int startgold;
  1479. X
  1480. X/*report on armies and allow changes*/
  1481. Xarmyrpt()
  1482. X{
  1483. X    int i,j;
  1484. X    int chg;
  1485. X    short army;
  1486. X    int men;
  1487. X    int oldx,oldy;
  1488. X    short oldarmy;
  1489. X    int done=0;
  1490. X    int position;
  1491. X    int isgod=0;
  1492. X    int count;    /*number of armies on current screen */
  1493. X    short armynum=0;    /*current nation id */
  1494. X    if(country==0) {
  1495. X        standout();
  1496. X        isgod=1;
  1497. X        clear();
  1498. X        mvaddstr(0,0,"SUPER USER; FOR WHAT NATION NUMBER:");
  1499. X        clrtoeol();
  1500. X        standend();
  1501. X        refresh();
  1502. X        echo();
  1503. X        scanw("%hd",&country);
  1504. X        if(country<0||country>NTOTAL) return;
  1505. X        noecho();
  1506. X    }
  1507. X    armynum=0;
  1508. X    /*new army screen*/
  1509. X    while(done==0) {
  1510. X        clear();
  1511. X        /*Operate on any armies that you wish*/
  1512. X        standout();
  1513. X        mvprintw(0,(COLS/2)-20,"ARMY STATS SUMMARY FOR %s",ntn[country].name);
  1514. X        standend();
  1515. X        /* give a army report */
  1516. X
  1517. X        mvaddstr(3,0,"soldiers  :");
  1518. X        mvaddstr(4,0,"movement  :");
  1519. X        mvaddstr(5,0,"x location:");
  1520. X        mvaddstr(6,0,"y location:");
  1521. X        mvaddstr(7,0,"status    :");
  1522. X
  1523. X        position=5;
  1524. X        count=0;
  1525. X        while((armynum<MAXARM)&&(count!=6)){
  1526. X            if(ASOLD>0) {
  1527. X                count++;
  1528. X                position+=10;
  1529. X                standout();
  1530. X                mvprintw(2,position,"%d:",armynum);
  1531. X                standend();
  1532. X                mvprintw(3,position,"%d",ASOLD);
  1533. X                mvprintw(4,position,"%d",AMOVE);
  1534. X                mvprintw(5,position,"%d",AXLOC);
  1535. X                mvprintw(6,position,"%d",AYLOC);
  1536. X                mvprintw(7,position,"%s",*(soldname+ASTAT));
  1537. X            }
  1538. X            armynum++;
  1539. X        }
  1540. X        if(armynum>=MAXARM) done=1;
  1541. X
  1542. X        standout();
  1543. X        mvaddstr(12,(COLS/2)-10,"HIT SPACE KEY IF DONE");
  1544. X        mvaddstr(13,(COLS/2)-14,"HIT RETURN TO CHANGE AN ARMY");
  1545. X        mvaddstr(14,(COLS/2)-14,"HIT ANY OTHER KEY TO CONTINUE");
  1546. X        standend();
  1547. X        refresh();
  1548. X        if ((army=getch())==' ') done=1;
  1549. X        if (army=='\n'){
  1550. X            mvaddstr(16,0,"WHAT ARMY DO YOU WANT TO CHANGE:");
  1551. X            clrtoeol();
  1552. X            refresh();
  1553. X            echo();
  1554. X            scanw("%hd",&armynum);
  1555. X            noecho();
  1556. X            if((armynum<0)||(armynum>MAXARM)) return;
  1557. X            mvaddstr(18,0,"1) CHANGE STATUS, 2) TRANSFER / MERGE, 3) SPLIT ARMY, 4) DISBAND ARMY:");
  1558. X            clrtoeol();
  1559. X            if(isgod==1) mvaddstr(20,0,"5) LOCATION, 6) SOLDIERS:");
  1560. X            refresh();
  1561. X            switch(getch()){
  1562. X            case '1':
  1563. X                mvaddstr(21,0,"1=MARCH, 2=SCOUT, 3=ATTACK, 4=DEFEND, 5=GARRISON");
  1564. X                clrtoeol();
  1565. X                refresh();
  1566. X                scanw("%d",&chg);
  1567. X                if(chg<1) return;
  1568. X                if(chg>5) return;
  1569. X                if((chg==2)&&(ASOLD>25)){
  1570. X                    clear();
  1571. X                    mvaddstr(12,(COLS/2)-6,"NEED < 25 MEN TO SCOUT");
  1572. X                    mvaddstr(13,(COLS/2)-12,"HIT ANY KEY TO CONTINUE");
  1573. X                    refresh();
  1574. X                    getch();
  1575. X                    if(isgod==1) country=0;
  1576. X                    return;
  1577. X                }
  1578. X                else if((chg>0)&&(chg<7)) {
  1579. X                    ASTAT=chg; 
  1580. X                    AADJSTAT;
  1581. X                }
  1582. X                break;
  1583. X            case '2':
  1584. X                oldx=AXLOC;
  1585. X                oldy=AYLOC;
  1586. X                oldarmy=armynum;
  1587. X                mvaddstr(22,0,"TO WHAT ARMY: ");
  1588. X                clrtoeol();
  1589. X                refresh();
  1590. X                echo();
  1591. X                scanw("%hd",&armynum);
  1592. X                if(armynum==oldarmy) {
  1593. X                    mvprintw(23,0,"SORRY -- SAME (%d,%d",armynum,oldarmy);
  1594. X                    refresh();
  1595. X                    getch();
  1596. X                }
  1597. X                else if((armynum<0)||(armynum>MAXARM)){
  1598. X                    mvprintw(23,0,"SORRY -- INVALID ARMY %d",armynum);
  1599. X                    refresh();
  1600. X                    getch();
  1601. X                }
  1602. X                else if(ntn[country].arm[oldarmy].stat==SCOUT){
  1603. X                    mvaddstr(23,0,"SORRY -- ORIGIN ARMY IS SCOUTING");
  1604. X                    refresh();
  1605. X                    getch();
  1606. X                }
  1607. X                else if(ASTAT==SCOUT){
  1608. X                    mvaddstr(23,0,"SORRY -- TARGET ARMY IS SCOUTING");
  1609. X                    refresh();
  1610. X                    getch();
  1611. X                }
  1612. X                else if((oldx==AXLOC)&&(oldy==AYLOC)&&(ASOLD>0)) {
  1613. X                    ASOLD+= ntn[country].arm[oldarmy].sold;
  1614. X                    ntn[country].arm[oldarmy].sold=0;
  1615. X                    AADJMEN;
  1616. X                    if(AMOVE>ntn[country].arm[oldarmy].smove)
  1617. X                        AMOVE=ntn[country].arm[oldarmy].smove;
  1618. X                    AADJMOV;
  1619. X                    armynum=oldarmy;
  1620. X                    AADJMEN;
  1621. X                }
  1622. X                else {
  1623. X                    mvaddstr(23,0,"Armies not together (hit any key) ");
  1624. X                    refresh();
  1625. X                    getch();
  1626. X                }
  1627. X                noecho();
  1628. X                break;
  1629. X            case '3':
  1630. X                mvaddstr(21,0,"HOW MANY MEN TO SPLIT: ");
  1631. X                clrtoeol();
  1632. X                refresh();
  1633. X                echo();
  1634. X                scanw("%d",&men);
  1635. X                noecho();
  1636. X                if((armynum<0)||(armynum>MAXARM)) return;
  1637. X                if((men<25)||(ASOLD-men<25)){
  1638. X                    mvaddstr(23,0,"TOO FEW MEN TRANSFERED OR LEFT");
  1639. X                    refresh();
  1640. X                    getch();
  1641. X                }
  1642. X                else if(men<ASOLD){
  1643. X                    ASOLD-=men;
  1644. X                    AADJMEN;
  1645. X                    oldarmy=armynum;
  1646. X                    oldx=AXLOC;
  1647. X                    oldy=AYLOC;
  1648. X                    armynum=(-1);
  1649. X                    for(army=0;army<MAXARM;army++)
  1650. X                        if(ntn[country].arm[army].sold==0){
  1651. X                            if(armynum==(-1)) armynum=army;
  1652. X                        }
  1653. X                    /*overflow*/
  1654. X                    if(armynum==(-1)) {
  1655. X                        mvaddstr(23,0,"TOO MANY ARMIES: ");
  1656. X                        armynum=oldarmy;
  1657. X                        ASOLD+=men;
  1658. X                        AADJMEN;
  1659. X                    }
  1660. X                    else {
  1661. X                        AMOVE=ntn[country].arm[oldarmy].smove;
  1662. X                        ASTAT=DEFEND;
  1663. X                        AXLOC=oldx;
  1664. X                        AYLOC=oldy;
  1665. X                        ASOLD=men;
  1666. X                        AADJSTAT;
  1667. X                        AADJMEN;
  1668. X                        AADJLOC;
  1669. X                        AADJMOV;
  1670. X                    }
  1671. X                }
  1672. X                else {
  1673. X                    mvaddstr(23,0,"TOO MANY MEN : ");
  1674. X                    refresh();
  1675. X                    getch();
  1676. X                }
  1677. X                break;
  1678. X            case '4':
  1679. X                if(sct[AXLOC][AYLOC].owner!=country){
  1680. X                    mvaddstr(21,0,"YOU DONT OWN SECTOR-- hit return");
  1681. X                    clrtoeol();
  1682. X                    refresh();
  1683. X                    getch();
  1684. X                }
  1685. X                else if(magic(country,VAMPIRE)==1){
  1686. X                    mvaddstr(21,0,"VAMPIRES CANT DISBAND--hit return");
  1687. X                    clrtoeol();
  1688. X                    refresh();
  1689. X                    getch();
  1690. X                }
  1691. X                else {
  1692. X                    i=AXLOC;
  1693. X                    j=AYLOC;
  1694. X                    sct[i][j].people+=ASOLD;
  1695. X                    ASOLD=0;
  1696. X                    AADJMEN;
  1697. X                    SADJCIV2;
  1698. X                }
  1699. X                break;
  1700. X            case '5':
  1701. X                if(isgod==1){
  1702. X                    /*X LOCATION*/
  1703. X                    mvaddstr(21,0,"WHAT IS THE NEW X LOC: ");
  1704. X                    refresh();
  1705. X                    echo();
  1706. X                    scanw("%d",&men);
  1707. X                    AXLOC=men;
  1708. X                    /*Y LOCATION*/
  1709. X                    mvaddstr(21,0,"WHAT IS THE NEW Y LOC: ");
  1710. X                    refresh();
  1711. X                    scanw("%d",&men);
  1712. X                    noecho();
  1713. X                    AYLOC=men;
  1714. X                    AADJLOC;
  1715. X                }
  1716. X                break;
  1717. X            case '6':
  1718. X                if(isgod==1){
  1719. X                    /*SOLDIERS*/
  1720. X                    mvaddstr(21,0,"WHAT IS THE NEW TOTAL SOLDIERS: ");
  1721. X                    refresh();
  1722. X                    echo();
  1723. X                    scanw("%d",&men);
  1724. X                    noecho();
  1725. X                    ASOLD=men;
  1726. X                    AADJMEN;
  1727. X                }
  1728. X                break;
  1729. X            default:
  1730. X                mvaddstr(21,0,"ERROR : HIT ANY CHAR TO CONTINUE");
  1731. X                clrtoeol();
  1732. X                refresh();
  1733. X                getch();
  1734. X            }
  1735. X            noecho();
  1736. X            armynum=0;
  1737. X        }
  1738. X    }
  1739. X    if(isgod==1) country=0;
  1740. X}
  1741. X
  1742. Xbudget()
  1743. X{
  1744. X    register int xsctr,ysctr;
  1745. X    short armynum,nvynum;
  1746. X
  1747. X    int ingold=0,iniron=0,infood=0,incap=0,incity=0;
  1748. X    int revgold=0,reviron=0,revfood=0;
  1749. X    int expship=0,expsold=0;
  1750. X    int isgod=0;
  1751. X    if(country==0) {
  1752. X        isgod=1;
  1753. X        clear();
  1754. X        mvaddstr(0,0,"SUPER USER; FOR WHAT NATION NUMBER:");
  1755. X        clrtoeol();
  1756. X        refresh();
  1757. X        echo();
  1758. X        scanw("%hd",&country);
  1759. X        noecho();
  1760. X    }
  1761. X    clear();
  1762. X    standout();
  1763. X    mvaddstr(0,(COLS/2)-10,"NEXT YEARS BUDGET ESTIMATES");
  1764. X    standend();
  1765. X
  1766. X    for(xsctr=0;xsctr<MAPX;xsctr++) for(ysctr=0;ysctr<MAPX;ysctr++) if(sct[xsctr][ysctr].owner==country) {
  1767. X        if(sct[xsctr][ysctr].designation==DFARM){
  1768. X            infood+= sct[xsctr][ysctr].people;
  1769. X            revfood+=todigit(sct[xsctr][ysctr].vegitation)*sct[xsctr][ysctr].people*TAXFOOD/100;
  1770. X        }
  1771. X        else if(sct[xsctr][ysctr].designation==DMINE) {
  1772. X            iniron+= sct[xsctr][ysctr].people;
  1773. X            reviron+=sct[xsctr][ysctr].iron*sct[xsctr][ysctr].people*TAXIRON/100;
  1774. X        }
  1775. X        else if(sct[xsctr][ysctr].designation==DGOLDMINE) {
  1776. X            ingold+= sct[xsctr][ysctr].people;
  1777. X            revgold+=sct[xsctr][ysctr].gold*sct[xsctr][ysctr].people*TAXGOLD/100;
  1778. X        }
  1779. X        else if(sct[xsctr][ysctr].designation==DCAPITOL) incap+= sct[xsctr][ysctr].people;
  1780. X        else if(sct[xsctr][ysctr].designation==DCITY)    incity+= sct[xsctr][ysctr].people;
  1781. X    }
  1782. X    for(armynum=0;armynum<MAXARM;armynum++) if(ASOLD>0) expsold+= ASOLD;
  1783. X    for(nvynum=0;nvynum<MAXNAVY;nvynum++)
  1784. X        if(NWAR+NMER>0) expship+=(NWAR+NMER);
  1785. X
  1786. X    standout();
  1787. X    mvprintw(5,0,  "nation name is ...%s   ",ntn[country].name);
  1788. X    mvprintw(6,0,  "gold in treasury..$%8ld",ntn[country].tgold);
  1789. X    standend();
  1790. X    if(ntn[country].tfood<ntn[country].tciv) standout();
  1791. X    mvprintw(9,0,  "granary holds ....%8ld",ntn[country].tfood);
  1792. X    standend();
  1793. X    mvprintw(10,0, "jewels owned is...%8ld",ntn[country].jewels);
  1794. X    mvprintw(11,0, "iron ore owned is.%8ld",ntn[country].tiron);
  1795. X    mvprintw(7,30, "%5d people in gold mines:%8ld",ingold,revgold);
  1796. X    mvprintw(8,30, "%5d people in iron mines:%8ld",iniron,reviron);
  1797. X    mvprintw(9,30, "%5d people in farms:     %8ld",infood,revfood);
  1798. X    mvprintw(10,30,"%5d people in capital:   %8d",incap,incap*TAXCAP/100);
  1799. X    mvprintw(11,30,"%5d people in cities:    %8d",incity,incity*TAXCITY/100);
  1800. X    standout();
  1801. X    mvprintw(12,30,"%5d people TOTAL INCOME: %8d",ntn[country].tciv,revfood+reviron+revgold+(incap*TAXCAP/100)+(incity*TAXCITY/100));
  1802. X    standend();
  1803. X
  1804. X    if(magic(country,VAMPIRE)!=1) 
  1805. X    mvprintw(14,30,"%5d troops at %5d each:%8d",expsold,SOLDMAINT,expsold*SOLDMAINT);
  1806. X    else
  1807. X    mvprintw(14,30,"%5d troops at     0 each:0",expsold);
  1808. X    mvprintw(15,30,"%5d ships at %5d each: %8d",expship,SHIPMAINT,expship*SHIPMAINT);
  1809. X    mvprintw(16,30,"other expenses this turn:  %8ld",startgold-ntn[country].tgold);
  1810. X    standout();
  1811. X    mvprintw(17,30,"TOTAL EXPENSES:            %8d",(expsold*SOLDMAINT)+(expship*SHIPMAINT)+startgold-ntn[country].tgold);
  1812. X    mvprintw(18,30,"NET INCOME:                %8d",revfood+reviron+revgold+(incap*TAXCAP/100)+(incity*TAXCITY/100)-(expsold*SOLDMAINT)-(expship*SHIPMAINT)-startgold+ntn[country].tgold);
  1813. X    mvaddstr(20,(COLS/2)-12,"HIT ANY KEY TO CONTINUE");
  1814. X    standend();
  1815. X    refresh();
  1816. X    getch();
  1817. X
  1818. X    if(isgod==1) country=0;
  1819. X}
  1820. X
  1821. Xproduce()
  1822. X{
  1823. X    register int xsctr,ysctr;
  1824. X    short armynum;
  1825. X    int civilians=0, military=0;
  1826. X    int ingold=0 ,indesert=0,iniron=0,infood=0;
  1827. X    int revgold=0,reviron=0,revdesert=0,revfood=0;
  1828. X    int isgod=0;
  1829. X
  1830. X    if(country==0) {
  1831. X        isgod=1;
  1832. X        clear();
  1833. X        mvaddstr(0,0,"SUPER USER; FOR WHAT NATION NUMBER:");
  1834. X        clrtoeol();
  1835. X        refresh();
  1836. X        echo();
  1837. X        scanw("%hd",&country);
  1838. X        noecho();
  1839. X    }
  1840. X    clear();
  1841. X    standout();
  1842. X    mvaddstr(0,(COLS/2)-20,"NEXT YEARS PRODUCTION ESTIMATES");
  1843. X    standend();
  1844. X
  1845. X    for(xsctr=0;xsctr<MAPX;xsctr++) for(ysctr=0;ysctr<MAPX;ysctr++) if(sct[xsctr][ysctr].owner==country) {
  1846. X        civilians += sct[xsctr][ysctr].people;
  1847. X
  1848. X        if(sct[xsctr][ysctr].designation==DFARM){
  1849. X            infood+= sct[xsctr][ysctr].people;
  1850. X            revfood+=todigit(sct[xsctr][ysctr].vegitation)*sct[xsctr][ysctr].people;
  1851. X        }
  1852. X        else if(sct[xsctr][ysctr].designation==DMINE) {
  1853. X            iniron+= sct[xsctr][ysctr].people;
  1854. X            reviron+=sct[xsctr][ysctr].iron*sct[xsctr][ysctr].people;
  1855. X        }
  1856. X        else if(sct[xsctr][ysctr].designation==DGOLDMINE) {
  1857. X            ingold+= sct[xsctr][ysctr].people;
  1858. X            revgold+=sct[xsctr][ysctr].gold*sct[xsctr][ysctr].people;
  1859. X        }
  1860. X        else if(((magic(country,DERVISH)==1)||(magic(country,DESTROYER)==1))&&((sct[xsctr][ysctr].vegitation==ICE)||(sct[xsctr][ysctr].vegitation==DESERT))&&(sct[xsctr][ysctr].people>0)) {
  1861. X            indesert+= sct[xsctr][ysctr].people;
  1862. X            revdesert+=6*sct[xsctr][ysctr].people;
  1863. X        }
  1864. X    }
  1865. X    if(magic(sct[xsctr][ysctr].owner,MINER)==1) {
  1866. X        mvaddstr(20,0,"MINER");
  1867. X        reviron*=2;
  1868. X        revgold*=2;
  1869. X    }
  1870. X
  1871. X    standout();
  1872. X    mvprintw(5,0,  "nation name is ...%s   ",ntn[country].name);
  1873. X    mvprintw(6,0,  "gold in treasury..$%8d",ntn[country].tgold);
  1874. X    standend();
  1875. X    mvaddstr(8,0,  "FOOD PRODUCTION");
  1876. X    mvprintw(9,0,  "granary now holds......%8ld tons",ntn[country].tfood);
  1877. X    mvprintw(10,0, "%5d people in farms..%8d tons",infood,revfood);
  1878. X    if((magic(country,DERVISH)==1)||(magic(country,DESTROYER)==1)) {
  1879. X    mvprintw(11,0, "dervish: %5d people..%8d tons",indesert,revdesert);
  1880. X    }
  1881. X    for(armynum=0;armynum<MAXARM;armynum++) if(ASOLD>0) military+=ASOLD;
  1882. X    mvprintw(12,0, "%5d civilians eat....%8d tons",civilians,civilians);
  1883. X    mvprintw(13,0, "%5d soldiers  eat....%8d tons",military,military*2);
  1884. X    mvprintw(15,0, "TOTAL NET FOOD.........%8d tons",revfood+revdesert-civilians-military*2);
  1885. X    if(ntn[country].tfood+revfood+revdesert-civilians-military*2<FOODTHRESH*civilians) {
  1886. X    mvprintw(16,0, "TOTAL NEXT YEARS FOOD..%8ld tons",ntn[country].tfood+revfood+revdesert-civilians-military*2);
  1887. X    }
  1888. X    else{
  1889. X    mvprintw(16,0, "TOTAL NEXT YEARS FOOD..%8ld tons",FOODTHRESH*civilians);
  1890. X    mvprintw(17,0, "REVENUE FROM EXCESS....%8ld gold",ntn[country].tfood+revfood+revdesert-civilians-military*2-FOODTHRESH*civilians);
  1891. X    }
  1892. X
  1893. X    mvaddstr(8,40,  "OTHER PRODUCTION");
  1894. X    mvprintw(10,40, "jewels owned is............%8d",ntn[country].jewels);
  1895. X    mvprintw(11,40, "%5d people in goldmines :%8d",ingold,revgold);
  1896. X    mvprintw(12,40, "ESTIMATE NEXT YEARS JEWELS %8d",ntn[country].jewels+revgold);
  1897. X    mvprintw(14,40, "iron ore owned is..........%8ld",ntn[country].tiron);
  1898. X    mvprintw(15,40, "%5d people in iron mines:%8d",iniron,reviron);
  1899. X    mvprintw(16,40, "ESTIMATE NEXT YEARS IRON   %8ld",ntn[country].tiron+reviron);
  1900. X
  1901. X    mvaddstr(20,(COLS/2)-12,"HIT ANY KEY TO CONTINUE");
  1902. X    refresh();
  1903. X    getch();
  1904. X
  1905. X    if(isgod==1) country=0;
  1906. X}
  1907. X
  1908. X/*report on ships and allow changes */
  1909. Xfleetrpt()
  1910. X{
  1911. X    short navy;
  1912. X    short oldx,oldy,oldnavy;
  1913. X    short done=0;
  1914. X    int position;
  1915. X    int count;       /*screen number */
  1916. X    short nvynum=0;    /*current ship id */
  1917. X    short wships,mships;
  1918. X    int isgod=0;
  1919. X    if(country==0) {
  1920. X        standout();
  1921. X        isgod=1;
  1922. X        clear();
  1923. X        mvaddstr(0,0,"SUPER USER; FOR WHAT NATION NUMBER:");
  1924. X        clrtoeol();
  1925. X        standend();
  1926. X        refresh();
  1927. X        echo();
  1928. X        scanw("%hd",&country);
  1929. X        if(country<0||country>NTOTAL) return;
  1930. X        noecho();
  1931. X    }
  1932. X
  1933. X    count=0;
  1934. X    for(nvynum=0;nvynum<MAXNAVY;nvynum++) count+=NWAR+NMER;
  1935. X    if(count==0){
  1936. X        clear();
  1937. X        standout();
  1938. X        mvaddstr(5,(COLS/2)-6, "NO NAVIES ");
  1939. X        mvaddstr(15,(COLS/2)-14,"HIT ANY KEY TO CONTINUE");
  1940. X        standend();
  1941. X        done=1;
  1942. X        refresh();
  1943. X        if(isgod==1) country=0;
  1944. X        return;
  1945. X    }
  1946. X    nvynum=0;
  1947. X    while(done==0) {
  1948. X        clear();
  1949. X        /*Operate on any navies that you wish*/
  1950. X        standout();
  1951. X        mvprintw(0,(COLS/2)-20,"NAVY STATS SUMMARY FOR %s",ntn[country].name);
  1952. X        standend();
  1953. X        /* give a navy report */
  1954. X
  1955. X        mvaddstr(3,0, "warships  :");
  1956. X        mvaddstr(4,0, "merchant :");
  1957. X        mvaddstr(5,0, "x location:");
  1958. X        mvaddstr(6,0, "y location:");
  1959. X        mvaddstr(7,0,"move left :");
  1960. X
  1961. X        position=5;
  1962. X        count=0;
  1963. X        while((nvynum<MAXNAVY)&&(count!=6)){
  1964. X            if((NWAR+NMER)>0) {
  1965. X                count++;
  1966. X                position+=10;
  1967. X                standout();
  1968. X                mvprintw(2,position,"%d:",nvynum);
  1969. X                standend();
  1970. X                mvprintw(3,position,"%d",NWAR);
  1971. X                mvprintw(4,position,"%d",NMER);
  1972. X                mvprintw(5,position,"%d",NXLOC);
  1973. X                mvprintw(6,position,"%d",NYLOC);
  1974. X                mvprintw(7,position,"%d",NMOVE);
  1975. X            }
  1976. X            nvynum++;
  1977. X        }
  1978. X        if(nvynum>=MAXNAVY) done=1;
  1979. X
  1980. X        standout();
  1981. X        mvaddstr(12,(COLS/2)-10,"HIT SPACE KEY IF DONE");
  1982. X        mvaddstr(13,(COLS/2)-14,"HIT RETURN TO CHANGE A NAVY");
  1983. X        mvaddstr(14,(COLS/2)-14,"HIT ANY OTHER KEY TO CONTINUE");
  1984. X        standend();
  1985. X        refresh();
  1986. X        if ((navy=getch())==' ') done=1;
  1987. X        if (navy=='\n'){
  1988. X            mvaddstr(16,0,"WHAT NAVY DO YOU WANT TO CHANGE:");
  1989. X            clrtoeol();
  1990. X            refresh();
  1991. X            echo();
  1992. X            scanw("%hd",&nvynum);
  1993. X            noecho();
  1994. X            if((nvynum<0)||(nvynum>MAXNAVY)) return;
  1995. X            mvaddstr(18,0,"1) TRANSFER / MERGE, 2) SPLIT NAVY, 3) DISBAND NAVY:");
  1996. X            clrtoeol();
  1997. X            refresh();
  1998. X            switch(getch()){
  1999. X            case '1':
  2000. X                oldx=NXLOC;
  2001. X                oldy=NYLOC;
  2002. X                oldnavy=nvynum;
  2003. X                mvaddstr(22,0,"TO WHAT NAVY: ");
  2004. X                clrtoeol();
  2005. X                refresh();
  2006. X                echo();
  2007. X                scanw("%hd",&nvynum);
  2008. X                if(nvynum==oldnavy) {
  2009. X                    mvprintw(23,0,"SORRY -- SAME (%d,%d)",nvynum,oldnavy);
  2010. X                    refresh();
  2011. X                    getch();
  2012. X                }
  2013. X                else if((nvynum<0)||(nvynum>MAXNAVY)){
  2014. X                    mvprintw(23,0,"SORRY -- INVALID NAVY %d",nvynum);
  2015. X                    refresh();
  2016. X                    getch();
  2017. X                }
  2018. X                else if((oldx==NXLOC)&&(oldy==NYLOC)) {
  2019. X                    NWAR+=ntn[country].nvy[oldnavy].warships;
  2020. X                    NMER+=ntn[country].nvy[oldnavy].merchant;
  2021. X                    NADJSHP;
  2022. X                    if(NMOVE>ntn[country].nvy[oldnavy].smove)
  2023. X                        NMOVE=ntn[country].nvy[oldnavy].smove;
  2024. X                    NADJMOV;
  2025. X                    nvynum=oldnavy;
  2026. X                    NWAR=0;
  2027. X                    NMER=0;
  2028. X                    NADJSHP;
  2029. X                }
  2030. X                else {
  2031. X                    mvaddstr(23,0,"Navies not together (hit any key) ");
  2032. X                    refresh();
  2033. X                    getch();
  2034. X                }
  2035. X                noecho();
  2036. X                break;
  2037. X            case '2':
  2038. X                mvaddstr(21,0,"HOW MANY WARSHIPS TO SPLIT: ");
  2039. X                clrtoeol();
  2040. X                refresh();
  2041. X                echo();
  2042. X                scanw("%hd",&wships);
  2043. X                mvaddstr(21,0,"HOW MANY MERCHANTS TO SPLIT: ");
  2044. X                clrtoeol();
  2045. X                refresh();
  2046. X                scanw("%hd",&mships);
  2047. X                noecho();
  2048. X                if((wships<NWAR)&&(mships<NMER)){
  2049. X                    NWAR-=wships;
  2050. X                    NMER-=mships;
  2051. X                    NADJSHP;
  2052. X                    oldnavy=nvynum;
  2053. X                    oldx=NXLOC;
  2054. X                    oldy=NYLOC;
  2055. X                    navy=(-1);
  2056. X                    for(nvynum=0;nvynum<MAXNAVY;nvynum++)
  2057. X                        if((NWAR+NMER==0)&&(navy==(-1))) 
  2058. X                            navy=nvynum;
  2059. X                    nvynum=navy;
  2060. X                    /*overflow*/
  2061. X                    if(nvynum==(-1)) {
  2062. X                        mvaddstr(23,0,"TOO MANY NAVIES: ");
  2063. X                        nvynum=oldnavy;
  2064. X                        NWAR+=wships;
  2065. X                        NMER+=mships;
  2066. X                        NADJSHP;
  2067. X                    }
  2068. X                    else {
  2069. X                        NMOVE=ntn[country].nvy[oldnavy].smove;
  2070. X                        NXLOC=oldx;
  2071. X                        NYLOC=oldy;
  2072. X                        NWAR=wships;
  2073. X                        NMER=mships;
  2074. X                        NADJSHP;
  2075. X                        NADJLOC;
  2076. X                        NADJMOV;
  2077. X                    }
  2078. X                }
  2079. X                else {
  2080. X                    mvaddstr(23,0,"TOO MANY SHIPS: ");
  2081. X                    refresh();
  2082. X                    getch();
  2083. X                }
  2084. X                break;
  2085. X            case '3':
  2086. X                NWAR=0;
  2087. X                NMER=0;
  2088. X                NADJSHP;
  2089. X                break;
  2090. X            default:
  2091. X                mvaddstr(21,0,"ERROR : HIT ANY CHAR TO CONTINUE");
  2092. X                clrtoeol();
  2093. X                refresh();
  2094. X                getch();
  2095. X            }
  2096. X            noecho();
  2097. X            nvynum=0;
  2098. X        }
  2099. X    }
  2100. X    if(isgod==1) country=0;
  2101. X}
  2102. END_OF_reports.c
  2103. if test 17114 -ne `wc -c <reports.c`; then
  2104.     echo shar: \"reports.c\" unpacked with wrong size!
  2105. fi
  2106. # end of overwriting check
  2107. fi
  2108. if test -f run -a "${1}" != "-c" ; then 
  2109.   echo shar: Will not over-write existing file \"run\"
  2110. else
  2111. echo shar: Extracting \"run\" \(256 characters\)
  2112. sed "s/^X//" >run <<'END_OF_run'
  2113. X#RUN CONQUEST WHEN AT COMMAND DOES NOT EXIST
  2114. X#date 
  2115. X#while [ 1 ] 
  2116. X#do  
  2117. X#$(EXECUTABLE)/conquest -x 
  2118. X#/bin/sleep 86400 
  2119. X#done 
  2120. X
  2121. X#please read up on the at command,  this now, and 24 hours from the time run.
  2122. Xdate 
  2123. Xconquest -x
  2124. Xat now+1day << 'EOF' 
  2125. X    run
  2126. XEOF; 
  2127. END_OF_run
  2128. if test 256 -ne `wc -c <run`; then
  2129.     echo shar: \"run\" unpacked with wrong size!
  2130. fi
  2131. # end of overwriting check
  2132. fi
  2133. echo shar: End of archive 3 \(of 5\).
  2134. cp /dev/null ark3isdone
  2135. MISSING=""
  2136. for I in 1 2 3 4 5 ; do
  2137.     if test ! -f ark${I}isdone ; then
  2138.     MISSING="${MISSING} ${I}"
  2139.     fi
  2140. done
  2141. if test "${MISSING}" = "" ; then
  2142.     echo You have unpacked all 5 archives.
  2143.     rm -f ark[1-9]isdone
  2144. else
  2145.     echo You still need to unpack the following archives:
  2146.     echo "        " ${MISSING}
  2147. fi
  2148. ##  End of shell archive.
  2149. exit 0
  2150.